package day4;

/**
 * @author oldliu
 * @since 1.0
 */
public class Laoshi {
    private  String name;
    private int age;//老师必须大于20岁
    public Laoshi(){

    }
    public Laoshi(String n,int a){
        this.name=n;
        //this.age=a;
        setAge(a);
    }
    public void show(){
        System.out.println("这个老师名叫"+name+"，今年"+age+"岁了");
    }
    public void setName(String n){
        this.name=n;
    }
    public String getName(){
        return name;
    }
    //修改年龄
    public void setAge(int a){
        if(a<20||a>70){
            System.out.println("年龄"+a+"不合法");
            return;
        }
        this.age=a;
    }
    public int getAge(){
        return age;
    }
}
